import {request} from "@/utils/request";
import {getToken} from "@/utils/storage";

export function pageList(data) {
    return request({
        url:`/api/teacher/page/${data.pageNum}/${data.pageSize}`,
        method: 'get',
        headers: {"token": getToken()},
        params: {
            username: data.username,
            nickname: data.nickname,
            phone: data.phone,
            roleId: data.typeId
        }
    })
}

export function typeList() {
    return request({
        url:`/api/teacher/typeList`,
        method: 'get',
        headers: {"token": getToken()}
    })
}

export function removeByTid(id) {
    return request({
        url:`/api/teacher/remove/${id}`,
        method: 'delete',
        headers: {"token": getToken()}
    })
}

export function selectLog(id) {
    return request({
        url:`/api/teacher/getTeacherShangKeRecod/${id}`,
        method: "get",
        headers: {"token": getToken()}
    })
}

export function teacherList() {
    return request({
        url:`/api/teacher/list`,
        method: "get",
        headers: {"token": getToken()}
    })
}

export function addTeacher(teacher) {
    return request({
        url:`/api/teacher/save`,
        method: "post",
        headers: {"token": getToken()},
        data: {
            "username": teacher.username,
            "email": teacher.email,
            "phone": teacher.phone,
            "type": teacher.type,
            "nickname": teacher.name
        }
    })
}
